﻿using SIE.SCADA.ZemtDemo.Machines;
using SIE.SCADA.ZemtDemo.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SIE.SCADA.ZemtDemo.View
{
    /// <summary>
    /// UserControl1.xaml 的交互逻辑
    /// </summary>
    public partial class MainCustWindow : UserControl
    {
        private Dictionary<string, TabItem> tabItems = new Dictionary<string, TabItem>();

        public MainCustWindow()
        {
            InitializeComponent();
        }

        public void InitMachine(List<IBaseMachine> machines)
        {
            Application.Current.Dispatcher.Invoke((Action)(() =>
            {
                foreach (var item in machines)
                {
                    if (item is TorqueWrench pf4000)
                    {
                        var hmi = new StationView(pf4000);
                        TabItem tabItem = new TabItem() { Header = $"{item.BaseProtocol.DeviceDesc}", Tag = item.BaseProtocol.DeviceDesc,Content = hmi };
                        this.tabItems.Add(tabItem.Tag.ToString(), tabItem);
                        this.TabMachines.Items.Add(tabItem);
                    }
                }
            }));
        }
    }

}
